import java.util.HashSet;
import java.util.Set;

public class Leet1585 {
    public static void main(String[] args) {
        Leet1585 l = new Leet1585();
        System.out.println(l.isTransformable("12345","12345"));
    }
    public boolean isTransformable(String s, String t) {
        Set<Character> ss = new HashSet<>();
        Set<Character> tt = new HashSet<>();
        for(char ch:s.toCharArray())
            ss.add(ch);
        for (char ch:t.toCharArray())
            tt.add(ch);
        if (ss.size()!=tt.size())
            return false;

        for (char c:ss){
            int num = 0,num1 = 0;
            for(char ch:s.toCharArray()){
                if (ch==c)
                    num++;
            }
            for (char ch:t.toCharArray()){
                if (ch==c)
                    num1++;
            }
            if (num!=num1)
                return false;
        }
        return true;
    }
}
